#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int a, b;
    cin >> a >> b;
    if(a == b && b & 1) {
        for(int i = 3; i * i <= b; i++) {
            if(b % i == 0) {
                cout << i << ' ' << b - i << endl;
                return;
            }
        }
        cout << -1 << endl;
        return;
    }
    if(b & 1) b--;
    b /= 2;
    if(b == 1) {
        cout << -1 << endl;
        return;       
    }
    cout << b << ' ' << b << endl;
}

signed main() {
    int t; cin >> t;
    while(t--) solve();
    return 0;
}